package BitManipulation;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class _187_RepeatedDNASequences {
    //HashSet solution
    public List<String> findRepeatedDnaSequences(String s) {
        Set<String> check = new HashSet<>();
        Set<String> dupli = new HashSet<>();
        for (int i = 0; i <= s.length() - 10; i++) {
            String sbs = s.substring(i, i + 10);
            if (!check.contains(sbs)) {
                check.add(sbs);
            } else {
                dupli.add(sbs);
            }
        }
        return new ArrayList(dupli);
    }
}
